//
//  ImageController.m
//  newView
//
//  Created by yjl on 14-6-20.
//  Copyright (c) 2014年 上海傲融软件公司. All rights reserved.
//

#import "ImageController.h"
#import "CPKenburnsView.h"

@interface ImageController ()

@end

@implementation ImageController
{
    CPKenburnsView *kenbunrsView;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.textview setBackgroundColor:[UIColor clearColor]];
    self.textview.font = [UIFont fontWithName:@"STXingkai" size:20];
    
    kenbunrsView = [[CPKenburnsView alloc] initWithFrame:self.view.bounds];
    kenbunrsView.image = [UIImage imageNamed:@"image1.jpeg"];
    [self.view insertSubview:kenbunrsView belowSubview:self.textview];
    
    //long press to show whole image
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showWholeImage:)];
    longPress.minimumPressDuration = .3f;
    [kenbunrsView addGestureRecognizer:longPress];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)showWholeImage:(UILongPressGestureRecognizer *)gesture
{
    switch (gesture.state) {
        case UIGestureRecognizerStateBegan:
            [kenbunrsView showWholeImage];
            break;
        case UIGestureRecognizerStateEnded:
        case UIGestureRecognizerStateCancelled:
            [kenbunrsView zoomAndRestartAnimation];
            break;
        default:
            break;
    }
}


@end
